package com.ss.android.article.base.feature.app;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.browser.R;
import com.ss.android.common.lib.MobClickCombiner;

public final class PushPermissionDlg extends Dialog implements View.OnTouchListener {
    public ImageView mTopImage;
    public TextView mContentTitle;
    public TextView mContentText;
    public TextView mDialogConfirm;
    public Context mContext;
    public String f;
    public Drawable g;
    private FrameLayout mRoot;
    private ImageView mDialogCancel;

    public PushPermissionDlg(Context context, String arg7) {
        super(context, R.style.ef);
        float v2 = 1f;
        float v1 = 0.5f;
        this.setContentView(com.ss.android.article.browser.R.layout.dialog_push_guide);
        this.mContext = context;
        this.f = arg7;
        this.mRoot = this.findViewById(com.ss.android.article.browser.R.id.root);
        this.mTopImage = this.findViewById(com.ss.android.article.browser.R.id.top_image);
        this.mContentTitle = this.findViewById(com.ss.android.article.browser.R.id.content_title);
        this.mContentText = this.findViewById(com.ss.android.article.browser.R.id.content_text);
        this.mDialogCancel = this.findViewById(com.ss.android.article.browser.R.id.dialog_cancel);
        this.mDialogConfirm = this.findViewById(com.ss.android.article.browser.R.id.dialog_confirm);
        this.mDialogCancel.setOnClickListener(new i(this));
        AppData.getInstance();
        boolean isNightMode = AppData.isNightMode();
        this.mRoot.setBackgroundResource(com.ss.android.article.browser.R.drawable.background_permission_dialog_2);
        float v0 = isNightMode ? v1 : v2;
        this.mTopImage.setAlpha(v0);
        if(!isNightMode) {
            v1 = v2;
        }
        this.mDialogCancel.setAlpha(v1);
        this.mContentTitle.setTextColor(this.mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi1));
        this.mContentText.setTextColor(this.mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi3));
        this.mDialogConfirm.setTextColor(this.mContext.getResources().getColor(com.ss.android.article.browser.R.color.update_comment_more_text_selector));
        this.mDialogCancel.setOnTouchListener(this);
        this.mDialogConfirm.setOnTouchListener(this);
        this.setCanceledOnTouchOutside(true);
    }

    public final void a() {
        if(((this.mContext instanceof Activity)) && !((Activity)this.mContext).isFinishing() && (this.isShowing())) {
            this.dismiss();
        }
    }

    public final void dismiss() {
        if(this.g != null && ((this.g instanceof AnimationDrawable))) {
            Drawable v0 = this.g;
            if(((AnimationDrawable)v0).isRunning()) {
                ((AnimationDrawable)v0).stop();
            }
        }

        super.dismiss();
    }

    public final boolean onTouch(View arg2, MotionEvent arg3) {
        switch(arg3.getAction()) {
            case 0: {
                arg2.setAlpha(0.5f);
                break;
            }
            case 1: 
            case 3: {
                arg2.setAlpha(1f);
                break;
            }
        }

        return false;
    }

    public final void show() {
        super.show();
        if(this.g != null && ((this.g instanceof AnimationDrawable))) {
            Drawable v0 = this.g;
            if(!((AnimationDrawable)v0).isRunning()) {
                ((AnimationDrawable)v0).start();
            }
        }

        MobClickCombiner.onEvent(this.mContext, "pop", this.f + "_show");
    }
}

